<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hhkj.${projectCode}.admin.${packageCode}.mapper.${objectCode}Mapper">
    <resultMap id="selectPoResultMap" type="com.hhkj.${projectCode}.admin.${packageCode}.model.podo.${objectCode}Po">
    </resultMap>

    <sql id="selectPo">
        SELECT
        ${tableCodeAbbr}.*
        FROM
        ${tableCode} ${tableCodeAbbr}
    </sql>

    <sql id="conditionDo">
        <if test="conditionDo != null">
        <#list fieldList as var>
            <if test="conditionDo.${var.javaCode} != null">
                AND ${tableCodeAbbr}.${var.sqlCode} = <#noparse>#{</#noparse>conditionDo.${var.javaCode}<#noparse>}</#noparse>
            </if>
        </#list>
        </if>
        AND ${tableCodeAbbr}.del_flag = 0
    </sql>

    <select id="pagingPoByDo" resultMap="selectPoResultMap">
        <include refid="selectPo"/>
        <where>
            <include refid="conditionDo"/>
        </where>
        ORDER BY ${tableCodeAbbr}.id DESC
    </select>

    <select id="listPoByDo" resultMap="selectPoResultMap">
        <include refid="selectPo"/>
        <where>
            <include refid="conditionDo"/>
        </where>
        ORDER BY ${tableCodeAbbr}.id DESC
    </select>

    <select id="getPoByDo" resultMap="selectPoResultMap">
        <include refid="selectPo"/>
        <where>
            <include refid="conditionDo"/>
        </where>
        ORDER BY ${tableCodeAbbr}.id DESC
        LIMIT 0,1
    </select>

    <select id="getPoById" resultMap="selectPoResultMap">
        <include refid="selectPo"/>
        WHERE ${tableCodeAbbr}.id = <#noparse>#{id}</#noparse> AND ${tableCodeAbbr}.del_flag = 0
        ORDER BY ${tableCodeAbbr}.id DESC
        LIMIT 0,1
    </select>
</mapper>